﻿var ToolContainer = new (function () {
    var This = this
		, Main = null //the jQuery object holding the DIV#Main obejct
		, Body = null //the jQuery object holding the BODY object
		, currentHeight = 0
		, offset = 50
    ;
    this.load = function () {
        Main = $('#Main');
        Body = $('body');
    };
    this.checkHeight = function (minHeightOffset) {
        /*
            Check to see if the height of the tool is smaller than the actual minimal height of the tool can be and then set the minHeight to the main tool container
            minHeightOffset - [optional][int] Allows you to set an extra offset in addition to the default offset. (In reallity holds the quickMessagePreview height of [PressReleaseItemObejct])
        */
        var height = Main.height();
        if (height < currentHeight) {
            return;
        }

        height += offset;

        if (typeof minHeightOffset == 'number') {
            height += minHeightOffset;
        }
        currentHeight = height;
        Body.css({
            minHeight: height
        });
        minPageHeightSet = true;
    };
})();
var SortingContainerObject = function () {

    this.root = $('#SortingContainer');

    var This = this;

    this.show = Utility.Effects.show;
    this.hide = Utility.Effects.hide;

    function _init() {
        This.root.animate({ opacity: 0, height: '0px' }, 0);
    }
    _init();
};
var TotalContainerObject = function (areTabsHidden) {

    this.root = $('#TotalContainer');

    var nr = $('#TotalNr'), This = this;

    this.show = function (intTotal) {
        if (typeof intTotal == 'number')
            nr.text(Utility.getArabicNumbers(intTotal));
        Utility.Effects.show(this);
    };
    this.hide = Utility.Effects.hide;

    function _init() {
        if (areTabsHidden) {
            This.root.addClass("NoTabsVisible");
        } else {
            This.root.animate({ opacity: 0, height: '0px' }, 0);
        }
    }
    _init();
};
var ErrorContainerObject = function () {
    this.root = $('#ErrorContainer');

    var This = this;

    this.show = Utility.Effects.show;
    this.hide = Utility.Effects.hide;

    function _init() {
        This.root.animate({ opacity: 0, height: '0px' }, 0);
    }
    _init();
};
var ResizeObject = function (intLayout) {
    /*
        Adds in and controls the event that adds the class name to the body to give IE8- width controls that mimic the @media query
        intLayout - Integer, the [PressReleasesObject].layout of this tool.
        
        Remarks:
        Must be called after load
    */
    var This = this
		, body = document.getElementsByTagName('body')[0]
    ;

    /********************************************************************************
	These variables are commented out, because they need to be added using prototype.
	---------------------------------------------------------------------------------
	
	this.ieCssURL = ""
		
	********************************************************************************/

    function _init() {
        if (!document.all || Utility.getDocumentModeIE() > 8 || intLayout == 0 || typeof This.ieCssURL != 'string')
            return;

        Utility.addCssFile(This.ieCssURL);

        $(window).resize(windowResize);
        windowResize();
    }

    function windowResize() {
        var width = parseFloat(body.offsetWidth), className = "";
        switch (intLayout) {
            case 1:
            case 2:
                if (width < 350 && width >= 250) {
                    className = "IE8-_250-350";
                } else if (width < 250) {
                    className = "IE8-_250-";
                }
                break;
            case 3:
                if (width < 500 && width >= 350) {
                    className = "IE8-_350-500";
                } else if (width < 350) {
                    className = "IE8-_350-";
                }
                break;
            case 4:
                if (width < 400 && width >= 300) {
                    className = "IE8-_300-400";
                } else if (width < 300) {
                    className = "IE8-_300-";
                }
                break;
        }
        body.className = className;
    }

    _init();
};